package com.atung.parking.mapper;

import com.atung.parking.entity.BusParkingOrders;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Administrator
 */
@Mapper
public interface BusParkingOrdersMapper extends BaseMapper<BusParkingOrders> {
    @Update("UPDATE bus_parking_orders " +
            "SET order_payment_time = #{paymentTime}, order_status = #{status} " +
            "WHERE id = #{orderId}")
    Boolean updateStatusById(@Param("orderId") Long orderId,
                 @Param("paymentTime") String paymentTime,
                 @Param("status") Integer status);

    @Select("SELECT * " +
            "FROM bus_parking_orders " +
            "WHERE order_status=201   AND FROM_UNIXTIME(creator_time / 1000) < NOW() - INTERVAL 3 MINUTE;")
    List<BusParkingOrders> select30MinAgo();


    @Update("UPDATE bus_parking_orders " +
            "SET order_status = 203 " +
            "WHERE id = #{orderId}")
    Boolean cancelOrderById(@Param("orderId") Long orderId);
}

